/**
 * Definition for a binary tree node.
 * struct TreeNode {
 *     int val;
 *     TreeNode *left;
 *     TreeNode *right;
 *     TreeNode(int x) : val(x), left(NULL), right(NULL) {}
 * };
 */
class Solution {
public:
    int kthLargest(TreeNode* root, int k) {
        vector<int> array;
        helper(root,array);
        return array[array.size()-k];
    }
    void helper(TreeNode* root,vector<int>& array){
        if(root==nullptr){
            return ;
        }
        int count=0;
        helper(root->left,array);
        array.push_back(root->val);
        helper(root->right,array);
    }
};